package com.dts.yjnb.service.admincontroller;

import com.dts.yjnb.service.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Excel导出Controller
 *
 * @author dts
 */
@RestController
@Api(tags = "报表导出相关接口")
@RequestMapping("/common/excel")
@Slf4j
public class ExcelExportController {

    @Autowired
    private ReportService reportService;

    /**
     * 导出产品数据
     * @param response HTTP响应
     */
    @GetMapping("product/export")
    @ApiOperation("导出产品数据")
    public void productExport(HttpServletResponse response) throws IOException {
        reportService.exportBusinessDate(response);
    }

    /**
     * 导出农贸市场数据
     */
    @GetMapping("market/export")
    @ApiOperation("导出农贸市场数据")
    public void marketExport(HttpServletResponse response) throws IOException {
        log.info("导出农贸市场数据");
        reportService.exportMarketData(response);
    }
}

